package com.zenithmind.library.pojo.domain;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zenithmind.common.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;

/**
 * 作者实体
 * 
 * @author ZenithMind
 * @since 2024-06-14
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(name = "作者实体", description = "作者信息")
@TableName("lib_author")
public class Author extends BaseEntity {

    @NotBlank(message = "作者姓名不能为空")
    @Size(max = 100, message = "作者姓名长度不能超过100个字符")
    @Schema(description = "作者姓名")
    private String name;

    @Size(max = 100, message = "作者英文名长度不能超过100个字符")
    @Schema(description = "作者英文名")
    private String nameEn;

    @Size(max = 50, message = "笔名长度不能超过50个字符")
    @Schema(description = "笔名")
    private String penName;

    @Schema(description = "性别 (0-女, 1-男, 2-其他)")
    private Integer gender;

    @Schema(description = "出生日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthDate;

    @Schema(description = "逝世日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate deathDate;

    @Size(max = 100, message = "国籍长度不能超过100个字符")
    @Schema(description = "国籍")
    private String nationality;

    @Schema(description = "作者简介")
    @Size(max = 2000, message = "作者简介长度不能超过2000个字符")
    private String biography;

    @Schema(description = "作者头像")
    private String avatar;

    @Schema(description = "官方网站")
    private String website;

    @Schema(description = "状态 (0-禁用, 1-启用)")
    private Integer status;

    @Schema(description = "作品数量")
    private Integer bookCount;

    @Schema(description = "总借阅次数")
    private Long totalBorrowCount;
}
